﻿#region License
/* Copyright (C) 2009 Tim Coulter
 * 
 * This file is part of ExtremeML.
 * 
 * ExtremeML is free software: you can redistribute
 * it and/or modify it under the terms of the GNU General Public
 * License, as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 * 
 * This software is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty
 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
 * the GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program. If not, see http://www.gnu.org/licenses/.
*/
#endregion

using DocumentFormat.OpenXml.Packaging;
using d = DocumentFormat.OpenXml.Drawing;

namespace ExtremeML.Packaging
{
	// This is a partial class that adds custom functionality to its auto-generated partner.
	public sealed partial class ThemePartWrapper
	{
		#region Custom Properties

		/// <summary>
		/// Gets the containing package as a <see cref="SpreadsheetDocumentWrapper"/>.
		/// </summary>
		public SpreadsheetDocumentWrapper Spreadsheet
		{
			get { return (SpreadsheetDocumentWrapper)Package; }
		}

		#endregion
		#region Custom Methods


		#endregion
		#region Overrides


		#endregion
		#region Implementation Methods


		#endregion
		#region Static Methods

		/// <summary>
		/// Returns a <see cref="ThemePart"/> populated with custom default content.
		/// </summary>
		/// <param name="container">The parent <see cref="OpenXmlPartContainer"/> instance.</param>
        /// <param name="args">A parameter array of <see cref="object"/> containing member initialization arguments.</param>
        /// <returns>A new instance of <see cref="ThemePart"/>.</returns>
		internal static new ThemePart CreateCustomDefaultPart(
			OpenXmlPartContainer container,
            params object[] args)
		{
			var part = container.AddNewPart<ThemePart>();

			var theme = new d.Theme(
				new d.ThemeElements(
					new d.ColorScheme(
						new d.Dark1Color(
							new d.SystemColor { Val = d.SystemColorValues.WindowText, LastColor = "000000" }),
						new d.Light1Color(
							new d.SystemColor { Val = d.SystemColorValues.Window, LastColor = "FFFFFF" }),
						new d.Dark2Color(
							new d.RgbColorModelHex{ Val = "1F497D" }),
						new d.Light2Color(
							new d.RgbColorModelHex{ Val = "EEECE1" }),
						new d.Accent1Color(
							new d.RgbColorModelHex{ Val = "4F81BD" }),
						new d.Accent2Color(
							new d.RgbColorModelHex{ Val = "C0504D" }),
						new d.Accent3Color(
							new d.RgbColorModelHex{ Val = "9BBB59" }),
						new d.Accent4Color(
							new d.RgbColorModelHex{ Val = "8064A2" }),
						new d.Accent5Color(
							new d.RgbColorModelHex{ Val = "4BACC6" }),
						new d.Accent6Color(
							new d.RgbColorModelHex{ Val = "F79646" }),
						new d.Hyperlink(
							new d.RgbColorModelHex{ Val = "0000FF" }),
						new d.FollowedHyperlinkColor(
							new d.RgbColorModelHex{ Val = "800080" })
					) { Name = "Office" },
					new d.FontScheme(
						new d.MajorFont(
							new d.LatinFont { Typeface = "Cambria" },
							new d.EastAsianFont { Typeface = "" },
							new d.ComplexScriptFont { Typeface = "" },
							new d.SupplementalFont { Script = "Jpan", Typeface = "ＭＳ Ｐゴシック" },
							new d.SupplementalFont { Script = "Hang", Typeface = "맑은 고딕" },
							new d.SupplementalFont { Script = "Hans", Typeface = "宋体" },
							new d.SupplementalFont { Script = "Hant", Typeface = "新細明體" },
							new d.SupplementalFont { Script = "Arab", Typeface = "Times New Roman" },
							new d.SupplementalFont { Script = "Hebr", Typeface = "Times New Roman" },
							new d.SupplementalFont { Script = "Thai", Typeface = "Tahoma" },
							new d.SupplementalFont { Script = "Ethi", Typeface = "Nyala" },
							new d.SupplementalFont { Script = "Beng", Typeface = "Vrinda" },
							new d.SupplementalFont { Script = "Gujr", Typeface = "Shruti" },
							new d.SupplementalFont { Script = "Khmr", Typeface = "MoolBoran" },
							new d.SupplementalFont { Script = "Knda", Typeface = "Tunga" },
							new d.SupplementalFont { Script = "Guru", Typeface = "Raavi" },
							new d.SupplementalFont { Script = "Cans", Typeface = "Euphemia" },
							new d.SupplementalFont { Script = "Cher", Typeface = "Plantagenet Cherokee" },
							new d.SupplementalFont { Script = "Yiii", Typeface = "Microsoft Yi Baiti" },
							new d.SupplementalFont { Script = "Tibt", Typeface = "Microsoft Himalaya" },
							new d.SupplementalFont { Script = "Thaa", Typeface = "MV Boli" },
							new d.SupplementalFont { Script = "Deva", Typeface = "Mangal" },
							new d.SupplementalFont { Script = "Telu", Typeface = "Gautami" },
							new d.SupplementalFont { Script = "Taml", Typeface = "Latha" },
							new d.SupplementalFont { Script = "Syrc", Typeface = "Estrangelo Edessa" },
							new d.SupplementalFont { Script = "Orya", Typeface = "Kalinga" },
							new d.SupplementalFont { Script = "Mlym", Typeface = "Kartika" },
							new d.SupplementalFont { Script = "Laoo", Typeface = "DokChampa" },
							new d.SupplementalFont { Script = "Sinh", Typeface = "Iskoola Pota" },
							new d.SupplementalFont { Script = "Mong", Typeface = "Mongolian Baiti" },
							new d.SupplementalFont { Script = "Viet", Typeface = "Times New Roman" },
							new d.SupplementalFont { Script = "Uigh", Typeface = "Microsoft Uighur" }),
						new d.MinorFont(
							new d.LatinFont { Typeface = "Calibri" },
							new d.EastAsianFont { Typeface = "" },
							new d.ComplexScriptFont { Typeface = "" },
							new d.SupplementalFont { Script = "Jpan", Typeface = "ＭＳ Ｐゴシック" },
							new d.SupplementalFont { Script = "Hang", Typeface = "맑은 고딕" },
							new d.SupplementalFont { Script = "Hans", Typeface = "宋体" },
							new d.SupplementalFont { Script = "Hant", Typeface = "新細明體" },
							new d.SupplementalFont { Script = "Arab", Typeface = "Arial" },
							new d.SupplementalFont { Script = "Hebr", Typeface = "Arial" },
							new d.SupplementalFont { Script = "Thai", Typeface = "Tahoma" },
							new d.SupplementalFont { Script = "Ethi", Typeface = "Nyala" },
							new d.SupplementalFont { Script = "Beng", Typeface = "Vrinda" },
							new d.SupplementalFont { Script = "Gujr", Typeface = "Shruti" },
							new d.SupplementalFont { Script = "Khmr", Typeface = "DaunPenh" },
							new d.SupplementalFont { Script = "Knda", Typeface = "Tunga" },
							new d.SupplementalFont { Script = "Guru", Typeface = "Raavi" },
							new d.SupplementalFont { Script = "Cans", Typeface = "Euphemia" },
							new d.SupplementalFont { Script = "Cher", Typeface = "Plantagenet Cherokee" },
							new d.SupplementalFont { Script = "Yiii", Typeface = "Microsoft Yi Baiti" },
							new d.SupplementalFont { Script = "Tibt", Typeface = "Microsoft Himalaya" },
							new d.SupplementalFont { Script = "Thaa", Typeface = "MV Boli" },
							new d.SupplementalFont { Script = "Deva", Typeface = "Mangal" },
							new d.SupplementalFont { Script = "Telu", Typeface = "Gautami" },
							new d.SupplementalFont { Script = "Taml", Typeface = "Latha" },
							new d.SupplementalFont { Script = "Syrc", Typeface = "Estrangelo Edessa" },
							new d.SupplementalFont { Script = "Orya", Typeface = "Kalinga" },
							new d.SupplementalFont { Script = "Mlym", Typeface = "Kartika" },
							new d.SupplementalFont { Script = "Laoo", Typeface = "DokChampa" },
							new d.SupplementalFont { Script = "Sinh", Typeface = "Iskoola Pota" },
							new d.SupplementalFont { Script = "Mong", Typeface = "Mongolian Baiti" },
							new d.SupplementalFont { Script = "Viet", Typeface = "Arial" },
							new d.SupplementalFont { Script = "Uigh", Typeface = "Microsoft Uighur" })
					) { Name = "Office" },
					new d.FormatScheme(
						new d.FillStyleList(
							new d.SolidFill(
								new d.SchemeColor { Val = d.SchemeColorValues.PhColor }),
							new d.GradientFill(
								new d.GradientStopList(
									new d.GradientStop(
										new d.SchemeColor(
											new d.Tint { Val = 50000 },
											new d.SaturationModulation { Val = 300000 }
										) { Val = d.SchemeColorValues.PhColor }
									) { Position = 0 },
									new d.GradientStop(
										new d.SchemeColor(
											new d.Tint { Val = 37000 },
											new d.SaturationModulation { Val = 300000 }
										) { Val = d.SchemeColorValues.PhColor }
									) { Position = 35000 },
									new d.GradientStop(
										new d.SchemeColor(
											new d.Tint { Val = 15000 },
											new d.SaturationModulation { Val = 350000 }
										) { Val = d.SchemeColorValues.PhColor }
									) { Position = 100000 }),
								new d.LinearGradientFill { Angle = 16200000, Scaled = true }
							) { RotateWithShape = true },
							new d.GradientFill(
								new d.GradientStopList(
									new d.GradientStop(
										new d.SchemeColor(
											new d.Shade { Val = 51000 },
											new d.SaturationModulation { Val = 130000 }
										) { Val = d.SchemeColorValues.PhColor }
									) { Position = 0 },
									new d.GradientStop(
										new d.SchemeColor(
											new d.Shade { Val = 93000 },
											new d.SaturationModulation { Val = 130000 }
										) { Val = d.SchemeColorValues.PhColor }
									) { Position = 80000 },
									new d.GradientStop(
										new d.SchemeColor(
											new d.Shade { Val = 94000 },
											new d.SaturationModulation { Val = 135000 }
										) { Val = d.SchemeColorValues.PhColor }
									) { Position = 100000 }),
								new d.LinearGradientFill { Angle = 16200000, Scaled = false }
							) { RotateWithShape = true }),
						new d.LineStyleList(
							new d.Outline(
								new d.SolidFill(
									new d.SchemeColor(
										new d.Shade { Val = 95000 },
										new d.SaturationModulation { Val = 105000 }
									) { Val = d.SchemeColorValues.PhColor }),
								new d.PresetDash { Val = d.PresetLineDashValues.Solid }
							) { Width = 9525, CapType = d.LineCapValues.Flat, CompoundLineType = d.CompoundLineValues.Single, Alignment = d.PenAlignmentValues.Center },
							new d.Outline(
								new d.SolidFill(
									new d.SchemeColor { Val = d.SchemeColorValues.PhColor }),
								new d.PresetDash { Val = d.PresetLineDashValues.Solid }
							) { Width = 25400, CapType = d.LineCapValues.Flat, CompoundLineType = d.CompoundLineValues.Single, Alignment = d.PenAlignmentValues.Center },
							new d.Outline(
								new d.SolidFill(
									new d.SchemeColor { Val = d.SchemeColorValues.PhColor }),
								new d.PresetDash { Val = d.PresetLineDashValues.Solid }
							) { Width = 38100, CapType = d.LineCapValues.Flat, CompoundLineType = d.CompoundLineValues.Single, Alignment = d.PenAlignmentValues.Center }),
						new d.EffectStyleList(
							new d.EffectStyle(
								new d.EffectList(
									new d.OuterShadow(
										new d.RgbColorModelHex(
											new d.Alpha { Val = 38000 }
										) { Val = "000000" }
									) { BlurRadius = 40000L, Distance = 20000L, Direction = 5400000, RotateWithShape = false })),
							new d.EffectStyle(
								new d.EffectList(
									new d.OuterShadow(
										new d.RgbColorModelHex(
											new d.Alpha { Val = 35000 }
										) { Val = "000000" }
									) { BlurRadius = 40000L, Distance = 23000L, Direction = 5400000, RotateWithShape = false })),
							new d.EffectStyle(
								new d.EffectList(
									new d.OuterShadow(
										new d.RgbColorModelHex(
											new d.Alpha { Val = 35000 }
										) { Val = "000000" }
									) { BlurRadius = 40000L, Distance = 23000L, Direction = 5400000, RotateWithShape = false }),
								new d.Scene3DType(
									new d.Camera(
										new d.Rotation { Latitude = 0, Longitude = 0, Revolution = 0 }
									) { Preset = d.PresetCameraValues.OrthographicFront },
									new d.LightRig(
										new d.Rotation { Latitude = 0, Longitude = 0, Revolution = 1200000 }
									) { Rig = d.LightRigValues.ThreePoints, Direction = d.LightRigDirectionValues.Top }),
								new d.Shape3DType(
									new d.BevelTop { Width = 63500L, Height = 25400L }))),
						new d.BackgroundFillStyleList(
							new d.SolidFill(
								new d.SchemeColor { Val = d.SchemeColorValues.PhColor }),
							new d.GradientFill(
								new d.GradientStopList(
									new d.GradientStop(
										new d.SchemeColor(
											new d.Tint { Val = 40000 },
											new d.SaturationModulation { Val = 350000 }
										) { Val = d.SchemeColorValues.PhColor }
									) { Position = 0 },
									new d.GradientStop(
										new d.SchemeColor(
											new d.Tint { Val = 45000 },
											new d.Shade { Val = 99000 },
											new d.SaturationModulation { Val = 350000 }
										) { Val = d.SchemeColorValues.PhColor }
									) { Position = 40000 },
									new d.GradientStop(
										new d.SchemeColor(
											new d.Shade { Val = 20000 },
											new d.SaturationModulation { Val = 255000 }
										) { Val = d.SchemeColorValues.PhColor }
									) { Position = 100000 }),
								new d.PathGradientFill(
									new d.FillToRectangle { Left = 50000, Top = -80000, Right = 50000, Bottom = 180000 }
								) { Path = d.PathShadeValues.Circle }
							) { RotateWithShape = true },
							new d.GradientFill(
								new d.GradientStopList(
									new d.GradientStop(
										new d.SchemeColor(
											new d.Tint { Val = 80000 },
											new d.SaturationModulation { Val = 300000 }
										) { Val = d.SchemeColorValues.PhColor }
									) { Position = 0 },
									new d.GradientStop(
										new d.SchemeColor(
											new d.Shade { Val = 30000 },
											new d.SaturationModulation { Val = 200000 }
										) { Val = d.SchemeColorValues.PhColor }
									) { Position = 100000 }),
								new d.PathGradientFill(
									new d.FillToRectangle { Left = 50000, Top = 50000, Right = 50000, Bottom = 50000 }
								) { Path = d.PathShadeValues.Circle }
							) { RotateWithShape = true })
					) { Name = "Office" }),
				new d.ObjectDefaults(),
				new d.ExtraColorSchemeList()
			) { Name = "Office Theme" };

			theme.Save(part);
			return part;
		}

		#endregion
	}
}
